/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package GUI;

import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

/**
 *
 * @author Dopsilon
 */
public class GUIMenu {
    private JMenuBar mainMenu;   
    private GUImain GUI;
    
    public GUIMenu(GUImain GUI){
        buildMenuBar();
        this.GUI = GUI;
        this.mainMenu.add(buildFileMenu());
        this.mainMenu.add(buildOptionsMenu());
        this.mainMenu.add(buildHelpMenu());
        
        
    }
    
    protected JMenuBar getMenuBar(){
        return this.mainMenu;
    }
    
    private void buildMenuBar(){
        this.mainMenu = new JMenuBar();        
    }
    
    private JMenu buildFileMenu(){
        JMenu fileMenu = new JMenu("File");
        TableListener fileListener = new TableListener(GUI);
        JMenuItem fileItem = new JMenuItem("New Table");
        fileItem.setActionCommand("newTable");
        fileItem.addActionListener(fileListener);
        fileMenu.add(fileItem);
        
        fileItem = new JMenuItem("Exit");
        fileItem.setActionCommand("quit");
        fileItem.addActionListener(fileListener);
        fileMenu.add(fileItem); 
        
        return fileMenu;
    }
    
    private JMenu buildOptionsMenu(){
        JMenu optionsMenu = new JMenu("Options");
        
        OptionsListener optListener = new OptionsListener(GUI);
        JMenuItem fileItem = new JMenuItem("Settings");
        fileItem.setActionCommand("options");
        fileItem.addActionListener(optListener);
        optionsMenu.add(fileItem);
        
      
        return optionsMenu;
    }
    
    private JMenu buildHelpMenu(){
        JMenu helpMenu = new JMenu("Help");
        
        return helpMenu;
    }
}
